package com.corner.model.leancloud.helper;

import android.test.ActivityUnitTestCase;
import android.test.suitebuilder.annotation.SmallTest;

import com.corner.app.App;
import com.corner.model.db.Conversation;
import com.corner.model.db.ConversationDao;
import com.corner.ui.activity.MainActivity;

import java.util.List;

import de.greenrobot.dao.query.QueryBuilder;
import de.greenrobot.dao.query.WhereCondition;


/**
 * Created by Administrator on 2015/8/12，22.18.
 * 描述：
 */
public class HistoryMessageHelperTest extends ActivityUnitTestCase<MainActivity> {

    public HistoryMessageHelperTest() {
        super(MainActivity.class);
    }

    public void testGetHistoryMessage() throws Exception {
        QueryBuilder.LOG_SQL = true;
        QueryBuilder.LOG_VALUES = true;
        WhereCondition condition1 = ConversationDao.Properties.MainUser.eq("2");
        WhereCondition condition2 = ConversationDao.Properties.CustomUser.eq("3");

        WhereCondition condition3 = ConversationDao.Properties.CustomUser.eq("2");
        WhereCondition condition4 = ConversationDao.Properties.MainUser.eq("3");

        App.application.initSession();
        QueryBuilder<Conversation> queryBuilder =
                App.application.daoSession.getConversationDao().queryBuilder();
        WhereCondition and1 = queryBuilder.and(condition1, condition2);
        WhereCondition and2 = queryBuilder.and(condition3, condition4);

        WhereCondition or = queryBuilder.or(and1, and2);
        List<Conversation> list = queryBuilder.where(or).list();
        assertEquals(true, true);
    }

    @SmallTest
    public void testBlah() throws Exception {
        testGetHistoryMessage();
    }
}